package org.lemon.transport.context.data.queue.message;

import lombok.Data;

import java.util.UUID;

@Data
public class ProtoQueueMessage<T extends com.google.protobuf.GeneratedMessageV3> implements QueueMessage {

    private final UUID key;
    protected final T value;
    private final QueueMessageHeaders headers;

    public ProtoQueueMessage(UUID key, T value) {
        this(key, value, new QueueMessageHeaders());
    }

    public ProtoQueueMessage(UUID key, T value, QueueMessageHeaders headers) {
        this.key = key;
        this.value = value;
        this.headers = headers;
    }

    @Override
    public UUID getKey() {
        return key;
    }

    @Override
    public QueueMessageHeaders getHeaders() {
        return headers;
    }

    @Override
    public byte[] getData() {
        return value.toByteArray();
    }
}
